﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

using LowLevelGraphics;
using LowLevelGraphics.Drawing.FloodFillModes;

namespace ImageRecognition2.MouseImageTools
{
    /// <summary>
    /// Flood Fill Tool
    /// </summary>
    public class FloodFillTool : MouseImageTool
    {
        private AbstractFloodFill m_FloodFillMode = new FloodFillMode();
        private Color m_Color = Color.FromArgb(127, 255, 255, 0);

        /// <summary>
        /// Flood Fill Tool
        /// </summary>
        /// <param name="_control"></param>
        public FloodFillTool(Control _control)
            : base(_control)
        {
        }

        /// <summary>
        /// Flood Fill Mode
        /// </summary>
        public AbstractFloodFill FloodFillMode
        {
            get { return m_FloodFillMode; }
            set { m_FloodFillMode = value; }
        }

        public override void OnMouseUp(object sender, MouseEventArgs e)
        {
            base.OnMouseUp(sender, e);
            UnsafeBitmap bitmap = MainFormSingleton.ActivePictureBox.BackgroundImage;
            m_FloodFillMode.Fill(bitmap, e.Location.X, e.Location.Y, m_Color);
            bitmap.UnlockImage();
        }
    }
}
